local skel = fk.CreateSkill{
  name = "lb__yetu",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["lb__yetu"] = "业途",
  --[":lb__yetu"] = "<b>锁定技</b>，当你受到其他角色造成的伤害时，改为回复等量体力；当你因牌回复体力时，改为失去等量体力。你的手牌上限改为已损失的体力值。当你回满体力值后，你死亡。",
  --9.15
  --[":lb__yetu"] = "<b>锁定技</b>，当你受到其他角色造成的伤害时，改为回复等量体力；当你因牌回复体力时，改为失去等量体力。当你体力为满时，你死亡。当你进入濒死时，将体力值调整至1。你的手牌上限改为已损失的体力值。",
  --9.16
  [":lb__yetu"] = "<b>锁定技</b>，当你受到其他角色造成的伤害时，改为回复等量体力；当你因牌回复体力时，改为失去等量体力。当你体力为满时，你死亡。当你进入濒死时，将体力值调整至2。你的手牌上限改为已损失的体力值。",

  ["$lb__yetu1"] = "你会带给我惊喜吗？",
  ["$lb__yetu2"] = "希望一切能在此终结……",
  ["$lb__yetu3"] = "已死之人，不知所惧。",
}

skel:addEffect(fk.DetermineDamageInflicted, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and data.from and data.from ~= player
  end,
  on_use = function(self, event, target, player, data)
    local n = data.damage
    data:preventDamage()
    player.room:recover{
      who = player,
      num = n,
      skillName = skel.name,
      recoverBy = data.from,
    }
  end,
})

skel:addEffect(fk.PreHpRecover, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and data.card
  end,
  on_use = function(self, event, target, player, data)
    local n = data.num
    data:preventRecover()
    player.room:loseHp( player, n, skel.name )
  end,
})

skel:addEffect(fk.EnterDying, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player
  end,
  on_use = function(self, event, target, player, data)
    if player.hp > 2 then
      player.room:loseHp( player, player.hp - 2, skel.name )  --保险起见
    else
      player.room:recover{
        who = player,
        num = -player.hp + 2,
        skillName = skel.name,
        recoverBy = player,
      }
    end
  end,
})

local yetu_dead = {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and not player:isWounded()
  end,
  on_use = function(self, event, target, player, data)
    player.room:killPlayer{
      who = player,
    }
  end,
}
skel:addEffect(fk.HpChanged, yetu_dead)
skel:addEffect(fk.MaxHpChanged, yetu_dead)
--[[没想好咋改
skel:addEffect(fk.BeforeHpChanged, {
  priority = 0.001,
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and not data.prevented and (player.hp + data.num) >= player.maxHp
  end,
  on_use = function(self, event, target, player, data)
    player.room:killPlayer{
      who = player,
    }
  end,
})
skel:addEffect(fk.BeforeMaxHpChanged, {
  priority = 0.001,
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and not data.prevented and math.max(player.maxHp + data.num, 0) <= player.hp
  end,
  on_use = function(self, event, target, player, data)
    player.room:killPlayer{
      who = player,
    }
  end,
})
skel:addAcquireEffect(function (self, player, is_start)
  if not player:isWounded() then
    player.room:killPlayer{
      who = player,
    }
  end
end)
--]]
skel:addEffect("maxcards", {
  fixed_func = function(self, player)
    if player:hasSkill(skel.name) then
      return player:getLostHp()
    end
  end,
})

return skel